package main;

public class Command {
	private static final String SLEEP = "sleep";
	private static final String SUM = "sum";
	
	private String name;
	private int argument;
	
	public Command(String name, String argument) {
		this.name = name;
		this.argument = Integer.parseInt(argument);
	}

	public void execute() {
		if (name.equals(SLEEP)) {
			try {
 				Thread.sleep(argument * 1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		} else if (name.equals(SUM)) {
			long sum = 0;
			for (long i=1; i <= argument; i++) {
				sum += i;
			}
		}	
	}
	
	public static void execute(String name, int argument) {
		if (name.equals(SLEEP)) {
			try {
 				Thread.sleep(argument * 1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		} else if (name.equals(SUM)) {
			long sum = 0;
			for (long i=1; i <= argument; i++) {
				sum += i;
			}
		}	
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getArgument() {
		return argument;
	}

	public void setArgument(int argument) {
		this.argument = argument;
	}

	
	@Override
	public String toString() {
		return name + " " + argument;
	}
}
